package com.ftg.learn.smhtml.service;


import com.ftg.learn.smhtml.mapper.DemoMapper;
import com.ftg.learn.smhtml.pojo.Dept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeptService {

    @Autowired
    DemoMapper demoMapper ;

    public List<Dept> showAll(String id,int page,int limit){
        return demoMapper.showAll(id,(page - 1) * limit,limit);
    }

    public int getCount(String id){
        return demoMapper.getCount(id).size();
    }

    public int addDept(Dept dept) {
        return demoMapper.addDept(dept);
    }

    public boolean delDept(String[] ids) {
        try {
            for(String id : ids) {
                demoMapper.delDept(id);
            }
            return true;
        }catch(Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    public Dept findOne(String id) {
        return demoMapper.findOne(id);
    }

    public int updateDept(Dept dept) {
        return demoMapper.updateDept(dept);
    }
}
